package peer.assist.message;

import java.net.DatagramPacket;

import peer.Message;
import peer.tools.ByteIntSwitch;
import peer.tools.ByteShortSwitch;

public class OtherOutAddressMessage extends Message{
	public short sType=peer.tools.MessageType.sType_Assist_OtherOutAddressMessage;
	int assistSessionId =0;
	byte[] dpData=new byte[8];
	public OtherOutAddressMessage(int assistSessionId){
		ByteShortSwitch.toByteArray(ver, dpData, 0);  //add: ver
		ByteShortSwitch.toByteArray(sType, dpData, 2);  //add: service type
		this.assistSessionId=assistSessionId;
		ByteIntSwitch.toByteArray(this.assistSessionId, dpData, 4);  //add: sessionId
		dp=new DatagramPacket(dpData,dpData.length);
	}
	
	public int getSessionId(){
		return assistSessionId ;
	}
	
	public OtherOutAddressMessage(DatagramPacket dp){
		this.dp=dp;
		dpData=dp.getData();
		ver=ByteShortSwitch.toShort(dpData, 0);
		sType=ByteShortSwitch.toShort(dpData, 2);
		assistSessionId=ByteIntSwitch.toInt(dpData, 4);
	}
}
